<template>
  <div>
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
      <!-- <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px"> -->
    <el-form-item label="时段名称" prop="activityTitle">
      <el-input v-model="dataForm.activityTitle" placeholder="整点抢购时段名称" maxlength="6" style="width: 445px"></el-input>
    </el-form-item>
    <el-form-item label="开始时间" prop="time">
      <template>
        <el-time-select
          placeholder="起始时间"
          v-model="startTime"
          :picker-options="{
          start: '00:00',
          step: '01:00',
          end: '24:00'
          }">
        </el-time-select>
        <el-time-select
          placeholder="结束时间"
          v-model="endTime"
          :picker-options="{
          start: '00:00',
          step: '01:00',
          end: '24:00',
          minTime: startTime
          }">
        </el-time-select>
      </template>
    </el-form-item>
    <el-form-item label="备注" prop="remark">
      <el-input v-model="dataForm.remark" placeholder="备注" style="width: 445px"></el-input>
    </el-form-item>
    <!-- </el-form> -->
      </el-form>
        <span style="margin-left: 445px">
          <!-- <el-button @click="sequenceVisible = false">取 消</el-button> -->
          <el-button type="primary" @click="dataFormSubmit()">确 定</el-button>
        </span><br/>
        <!-- <div v-show="!isShow" >
        <goods ref="Goods"></goods>
        <el-button @click="isShow=true" type="primary" round icon="el-icon-arrow-left">返回活动管理</el-button>
      </div> -->
  </div>
</template>

<script>
  export default {
    data () {
      return {
        startTime: '',
        endTime: '',
        visible: false,
        isShow: true,
        dataForm: {
          activityId: 0,
          activityTitle: '',
          remark: ''
        },
        dataRule: {
          activityTitle: [
            { required: true, message: '活动标题不能为空', trigger: 'blur' }
          ],
          startTime: [
            { required: true, message: '开始时间不能为空', trigger: 'blur' }
          ],
          endTime: [
            { required: true, message: '结束时间不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      // 获取数据列表
      getGoodsDataLists (id) {
        if (id != null) {
          this.dataForm.activityId = id
        }
        // this.dataListLoading = true
        // this.$http({
        //   url: this.$http.adornUrl('/activity/spikeGoods/queryActivityGoodsList'),
        //   method: 'get',
        //   params: this.$http.adornParams({
        //     'page': this.pageIndex,
        //     'limit': this.pageSize,
        //     'key': this.activityId,
        //     'goodsName': this.dataForm.goodsName
        //   })
        // }).then(({data}) => {
        //   if (data && data.code === 0) {
        //     this.dataList = data.data.list
        //     this.totalPage = data.data.totalCount
        //   } else {
        //     this.dataList = []
        //     this.totalPage = 0
        //   }
        //   this.dataListLoading = false
        // })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/activity/spike/addWholePointActivities`),
              method: 'post',
              data: this.$http.adornData({
                'activityId': this.dataForm.activityId,
                'activityTitle': this.dataForm.activityTitle,
                'startTime': this.startTime,
                'endTime': this.endTime,
                'remark': this.dataForm.remark
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500
                })
                this.dataForm.activityTitle = ''
                this.dataForm.remark = ''
                this.startTime = ''
                this.endTime = ''
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
<style>
  .characters{
    width:300px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
</style>
